package com.gitee.poi.plugin.core.handler;

import com.gitee.poi.plugin.annotations.core.Color;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Sheet;

import java.lang.reflect.Field;

public class ColorProcessor extends AbstractProcessor implements HandlerAnnotation {

    private Class supportAnnotation = Color.class;

    public CellStyle process(Font font, CellStyle style, Sheet sheet, Field field) {
        Color color = field.getAnnotation(Color.class);
        if (color != null) {
            font.setColor(color.value().getIndex());
            style.setFont(font);
        }
        return style;
    }

    public Class getSupportAnnotation() {
        return supportAnnotation;
    }
}
